import { reqAddressInfo, reqOrderInfo } from "@/api/index";

const state = {
  addressList: [],
  orderList: {},
};
const actions = {
  // 获取用户地址信息
  async AddressInfo({ commit }) {
    let result = await reqAddressInfo();
    if (result.data.code == 200) {
      commit("ADDRESSINFO", result.data.data);
    }
  },
  // 获取用户订单信息
  async orderInfo({ commit }) {
    let result = await reqOrderInfo();
    if (result.data.code == 200) {
      commit("ORDERINFO", result.data.data);
    }
  },
};
const mutations = {
  ADDRESSINFO(state, addressList) {
    state.addressList = addressList;
  },
  ORDERINFO(state, orderList) {
    state.orderList = orderList;
  },
};
const getters = {
    detailArrayList(state){
        return state.orderList.detailArrayList
    }
};
export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
};
